﻿using IntelligentAgriculture.Contracts.Interface;
using IntelligentAgriculture.Domain.Entity;
using IntelligentAgriculture.WebAPI.Application.Command.SheepAblactationCommand;
using MediatR;

namespace IntelligentAgriculture.WebAPI.Application.CommandHandler.SheepAblactationCommandHandler
{
    /// <summary>
    /// 中介者命令处理器：获取指定耳号的羊的档案
    /// </summary>
    public class GetBuildByEarCommandHandler : IRequestHandler<GetBuildByEarCommand, Results<List<Sheepfilemodel>>>
    {
        private readonly ISheepAblactationService _shepAblactationService;

        public GetBuildByEarCommandHandler(ISheepAblactationService shepAblactationService)
        {
            _shepAblactationService = shepAblactationService;
        }

        public async Task<Results<List<Sheepfilemodel>>> Handle(GetBuildByEarCommand request, CancellationToken cancellationToken)
        {
            var list = await _shepAblactationService.GetBuildByEar(request.earTagNumber);
            return Results<List<Sheepfilemodel>>.DataResult(list);
        }
    }
}
